<template>
  <div>
    <van-nav-bar title="添加地址">
      <template #left>
        <van-icon
          name="arrow-left"
          size="25"
          color="black"
          @click="$router.back()"
        />
      </template>
      <template #right>
        <van-icon name="ellipsis" size="25" color="black" />
      </template>
    </van-nav-bar>

    <van-address-edit
     :area-list="areaList"
      show-postal
      show-delete
      show-set-default
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete"
      @change-detail="onChangeDetail"
    />
  </div>
</template>

<script>
import { areaList } from "@vant/area-data";
import Vue from "vue";
import { AddressEdit,Toast } from "vant";
import { addAddress } from "../api/me";

Vue.use(AddressEdit);
export default {
  data() {
    return {
      areaList: areaList,
    };
  },
  methods: {
    //添加收货地址
    onSave(content) {
        // console.log(content);
      addAddress({
        userid:localStorage.getItem('id'),
        name:content.name,
        tel: content.tel,
        province:content.province,
        city:content.city,
        county:content.country,
        addressDetail:content.addressDetail,
        isDefault:content.isDefault,
      }).then((res) => {
          console.log(res);
          Toast('添加成功')
      });
    },
  },
};
</script>

<style>
</style>